home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Macintosh Drag and Drop / Demo Applications / Dragster / DragText Sources / cursor.c next >
Encoding:
C/C++ Source or Header  |  1995-01-03  |  1.8 KB  |  89 lines  |  [TEXT/KAHL]

  1. /*
  2.  *
  3.  *        cursor.c
  4.  *
  5.  *        Cursor handling routines.
  6.  *        
  7.  *
  8.  *        Author:        Rob Johnston
  9.  *        Date:        Friday, Janurary 17, 1992
  10.  *
  11.  *        12/30/94    JML        Code now compiles with Universal interfaces.
  12.  *
  13.  *        Copyright © 1992 Apple Computer, Inc.
  14.  *
  15.  */
  16.  
  17. #include <ToolUtils.h>
  18. #include "globals.h"
  19. #include "prototypes.h"
  20. #include "DTResources.h"
  21.  
  22.  
  23. short AdjustCursor(Point theLoc, RgnHandle theRgn)
  24.  
  25. {    WindowPtr    theWindow;
  26.     Document    *theDocument;
  27.     RgnHandle    arrowRgn, iBeamRgn, hiliteRgn;
  28.     Rect        theRect;
  29.     Point        thePoint;
  30.     MenuHandle    theMenu;
  31.     Str255        theName;
  32.  
  33.     if (gInBackground)
  34.         return;
  35.  
  36.     arrowRgn = NewRgn();
  37.     SetRectRgn(arrowRgn, -32767, -32767, 32767, 32767);
  38.  
  39.     if ((theWindow = FrontWindow()) && (theDocument = IsDocumentWindow(theWindow))) {
  40.         SetPort(theWindow);
  41.         iBeamRgn = NewRgn();
  42.         hiliteRgn = NewRgn();
  43.  
  44.         theRect = (**(theDocument->theTE)).viewRect;
  45.         LocalToGlobal((Point *)&(theRect.top));
  46.         LocalToGlobal((Point *)&(theRect.bottom));
  47.         RectRgn(iBeamRgn, &theRect);
  48.  
  49.         CopyRgn(theDocument->hiliteRgn, hiliteRgn);
  50.         thePoint.h = thePoint.v = 0;
  51.         LocalToGlobal(&thePoint);
  52.         OffsetRgn(hiliteRgn, thePoint.h, thePoint.v);
  53.  
  54.         DiffRgn(arrowRgn, hiliteRgn, arrowRgn);
  55.         DiffRgn(arrowRgn, iBeamRgn, arrowRgn);
  56.  
  57.         DiffRgn(iBeamRgn, hiliteRgn, iBeamRgn);
  58.  
  59.         if (PtInRgn(theLoc, iBeamRgn)) {
  60.             SetCursor(*GetCursor(iBeamCursor));
  61.             CopyRgn(iBeamRgn, theRgn);
  62.         } else if (PtInRgn(theLoc, hiliteRgn)) {
  63.             SetCursor(&qd.arrow);
  64.             CopyRgn(hiliteRgn, theRgn);
  65.         } else {
  66.             SetCursor(&qd.arrow);
  67.             CopyRgn(arrowRgn, theRgn);
  68.         }
  69.         
  70.         DisposeRgn(iBeamRgn);
  71.         DisposeRgn(hiliteRgn);
  72.     } else {
  73.         SetCursor(&qd.arrow);
  74.         CopyRgn(arrowRgn, theRgn);
  75.     }
  76.  
  77.     DisposeRgn(arrowRgn);
  78. }
  79.  
  80.  
  81. short GetGlobalMouse(Point *theLoc)
  82.  
  83. {    EventRecord        theEvent;
  84.     
  85.     OSEventAvail(0, &theEvent);
  86.     *theLoc = theEvent.where;
  87. }
  88.  
  89.